<template>
  <div class="index">
    <div id="main" style="width: 600px;height:400px;"></div>
  </div>
</template>

<script>
  import { listUser,getDetalis, getUser, delUser, addUser, updateUser,orderUser } from "@/api/system/good";
  import * as echarts from "echarts";
  export default {
        name: "index",
    created() {
      console.log("response.rows1")
      this.getList();
            console.log("this.seriesList",this.seriesList)

    },
    methods:{
          myEcharts(){
          // 基于准备好的dom，初始化echarts实例
          var myChart = this.$echarts.init(document.getElementById('main'));
          // 指定图表的配置项和数据
          var option = {
            title: {
              text: '物品统计图'
            },
            tooltip: {},
            legend: {
              data:['未预约数']
            },
            xAxis: {
              data: ["英语物品","音乐物品","数学物品","机房物品","其他物品"]
            },
            yAxis: {},
            series: [{
              name: '未预约数',
              type: 'bar',
              data: this.seriesList,
              smooth:true,
            }]
          };

          // 使用刚指定的配置项和数据显示图表。
          myChart.setOption(option);
        },
          /** 查询数学物品列表 */
          getList() {
            this.loading = true;
            console.log("response.rows2")
            getDetalis(this.queryParams).then(response => {
              this.goodList = response.data;
              for (let i = 0;i<this.goodList.length;i++){
                this.seriesList.push(this.goodList[i].remainder)
              }
              this.myEcharts();
              this.loading = false;
            });
          },
      },
        data(){
          return{
            goodList:[],
            seriesList:[],
            listdata: [102,200,200,200,200],
            myChart: null,
            timer: null,
            option: null,
          }
        },
        mounted() {
        this.myEcharts();

        },
  //   watch:{
  //     goodList(newList,oldList){
  //       console.log("newList",newList)
  //       for (let i = 0;i<newList.length;i++){
  //         this.seriesList.push(newList[i].remainder)
  //       }
  //       console.log("this.seriesList",this.seriesList)
  //       console.log("data",this.listdata)
  // }
  //   }

    }
</script>

<style scoped>

</style>
